# check_format.py
import json, subprocess, sys
preds = json.load(open("preds.json"))
ok = 0
for k, v in preds.items():
    patch = v["model_patch"]
    if not patch:
        continue
    # 简单验证：是不是统一 diff
    if patch.startswith("diff --git"):
        ok += 1
print(f"有效补丁 {ok}/{len(preds)}")
if ok == 0:
    sys.exit("❌ 没有一条有效 diff，请检查 prompt/模型输出")